package org.yujuan.springbootlearning;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.yujuan.springbootlearning.model.Task;
import org.yujuan.springbootlearning.service.TaskService;

import javax.annotation.PostConstruct;

@Slf4j
@MapperScan(value = "org.yujuan.springbootlearning.mapper")
@SpringBootApplication
public class SpringbootLearningApplication {

    @Value("${file.size:1}")
    private String fileSize;

    private static String fileSizeFinal;

    @PostConstruct
    public void init() {
        fileSizeFinal = fileSize;
    }


    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(SpringbootLearningApplication.class, args);
        log.info(run.getEnvironment().getProperty("file.size"));
        log.info(fileSizeFinal);
        try {
            RedisService redisService = run.getBean(RedisService.class);
            redisService.testRedis();
            TaskService taskService = run.getBean(TaskService.class);
            Task task = taskService.selectCustomTask(1L);
            System.out.println(task);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            run.close();
        }

    }
}
